package com.happystreet.engine
{
	import com.happystreet.develop.DeveloperPreferences;
	
	import flash.display.MovieClip;
	import flash.utils.getDefinitionByName;
	
	public class GameEngine extends MovieClip
	{
		public static var instance:GameEngine;
		public var theScene:CoreObject;
		
		public function GameEngine()
		{
			instance = this;
			this.theScene = new CoreObject();
		}
		
		/**
		 *创建MovieClip 
		 * @param name
		 * @return 
		 * 
		 */		
		public static function createMovieClip(name:String):MovieClip{
			var ClassReference:Class;
			
			try{
				ClassReference = (getDefinitionByName(name) as Class);
			}catch(error:ReferenceError){
				trace("ERROR! There is no movieclip called " + name);
				ClassReference = getDefinitionByName("ErrorSymbol") as Class;
			}
			
			return new ClassReference() as MovieClip;
		}
		/**
		 *添加到场景 
		 * @param obj
		 * 
		 */		
		public function addToScene(obj:CoreObject):void
		{
			this.theScene.add(obj);
		}
		/**
		 *从场景移除 
		 * @param obj
		 * 
		 */		
		public function removeFromScene(obj:CoreObject):void
		{
			this.theScene.remove(obj);
		}
	}
}